<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

	<div style="margin-bottom: 15px">

							<a   class='btn btn-primary ' onClick='openAddPet(this)' >新  增</a>	
						</div>
					
					<table id="searchTablePet" >
						<tr>
							<th w_index="no" width="2%;" style='cursor:auto'>
								序号
							</th>
							<th w_index="roomNum" width="10%;" style='cursor:auto'>
								房间号
							</th>
							<th w_index="customerName" width="10%;" style='cursor:auto'>
								客户名称
							</th>
							<th w_index="petName" width="10%;" style='cursor:auto'>
								宠物名称
							</th>
							<th w_index="opt" width="8%;" w_render="Oprate" style='cursor:auto'>
								操作
							</th>
							<th w_hidden="true" w_index="id">
								petId
							</th>
							<th w_hidden="true" w_index="id">
								roomId
							</th>
							<th w_hidden="true" w_index="id">
								customerId
							</th>
						</tr>
					</table>
					<script type="text/javascript">
				 	 var gridObjPet;
					$(function () {
						var roomInfoId ="${roomInfo.id}";
						gridObjPet = $.fn.bsgrid.init('searchTablePet', {
							url: "pet/getPetJsonData",
							autoLoad: true,
							pageSizeSelect: true, 
							multiSort: true ,
							displayBlankRows: false ,
							pagingLittleToolbar: true,
							stripeRows: true,
							rowHoverColor: true,
							pageSize: 15,
							otherParames:{"roomId":roomInfoId},
							curPage:1
							
					               					
						}); 
						$("#searchTable12_pt_outTab").css("width","98%")
						});
						function Oprate(record, rowIndex, colIndex, options) {
				            return '<a   href=javascript:edit(this,"'+gridObjPet.getRecordIndexValue(record, 'petId')+'");>编辑</a>&nbsp;&nbsp;<a   href=javascript:del("'+gridObj.getRecordIndexValue(record, 'petId')+'");>删除</a>';
				        }
					//打开宠物新增页面
				function openAddPet(obj){
					var roomInfoId ="${roomInfo.id}";
					var url = "pet/toAdd/"+roomInfoId;
					$(obj).attr('data-title',"宠物新增");
					$(obj).attr('_href',url);
					Hui_admin_tab(obj);
				}
				//编辑宠物信息页面
				function edit(obj,id){
					var url = "pet/toEditPet/"+id;
					$(obj).attr('data-title',"宠物编辑");
					$(obj).attr('_href',url);
					Hui_admin_tab(obj);
				}
				//删除宠物
				function del(id){
					//console.log(id);
					var url = "pet/delPet/"+id;
					layer.confirm("您确定删除吗？", {icon: 3}, function(index){
						jQuery.ajax({
							type:"post",
							async:false,
							url:url,
							success:function(data){
								if(data.success){
									window.layer.msg('删除成功！');
									window.gridObjPet.refreshPage();
									closeLayer();
								}else{
									layer.alert(data.msg,{icon:7});
								}
							}
						});
					});
				}
				
					</script>
						</div>

